package com.xlh.param.user;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.xlh.util.InputValidator;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

/**
 * 创建用户参数
 * <p>
 * Created by lx on 2019/2/21 0021.
 */
@Data
public class CreateUserParam extends UserParam {

    @ApiModelProperty(value = "用户id")
    @JsonIgnore
    private Long id;

    @ApiModelProperty(value = "工号/学号")
    @NotBlank(message = "请输入工号/学号")
    @Length(max = 20, message = "工号/学号不能超过20个字符")
    private String userNumber;

    @ApiModelProperty(value = "密码")
    @Length(max = 14, message = "密码不能超过14个字符")
    private String password;

    public String getUserNumber() {
        return userNumber == null ? null : InputValidator.regSpecialChar(userNumber).replaceAll(" ", "");
    }

    public String getPassword() {
        return password == null ? null : InputValidator.regSpecialChar(password);
    }

}
